<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.ahk</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (AutoHotKey) - Theme (Breeze Dark)"/>
</head><body style="background-color:#232629;color:#cfcfc2"><pre>
<span style="color:#7f8c8d;">^j</span>:: <span style="color:#7a7c7d;">; hotkey label</span>
::ftw::Free the whales <span style="color:#7a7c7d;">; hotstring label abbreviation</span>
::btw:: <span style="color:#7a7c7d;">; hotstring label action</span>
<span style="color:#7f8c8d;">MsgBox</span>, You typed btw.
<span style="color:#7f8c8d;">Run</span>, notepad.exe  <span style="color:#7a7c7d;">; Run Notepad when you press CTRL+N.</span>
<span style="color:#7f8c8d;">MsgBox</span>, Wow<span style="color:#7f8c8d;">!</span>
<span style="color:#7f8c8d;">MsgBox</span>, There are
<span style="color:#7f8c8d;">Run</span>, notepad.exe
<span style="color:#7f8c8d;">WinActivate</span>, Untitled - Notepad
<span style="color:#7f8c8d;">WinWaitActive</span>, Untitled - Notepad
<span style="color:#7f8c8d;">Send</span>, 7 lines{!}{<span style="color:#7f8c8d;">Enter</span>}
<span style="color:#7f8c8d;">SendInput</span>, inside the CTRL{+}J hotkey.
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7f8c8d;">Numpad0 &amp; Numpad1</span>::
<span style="color:#7f8c8d;">MsgBox</span>, You pressed Numpad1 while holding down Numpad0.
<span style="color:#7f8c8d;">Run</span>, notepad.exe
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7a7c7d;">; Untitled - Notepad</span>
<span style="color:#27aeae;font-weight:bold;">#IfWinActive</span> Untitled - Notepad
<span style="color:#7f8c8d;">!q</span>::
<span style="color:#7f8c8d;">MsgBox</span>, You pressed ALT<span style="color:#7f8c8d;">+Q</span> in Notepad.
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7a7c7d;">; Any window that isn't Untitled - Notepad</span>
<span style="color:#27aeae;font-weight:bold;">#IfWinActive</span>
<span style="color:#7f8c8d;">!q</span>::
<span style="color:#7f8c8d;">MsgBox</span>, You pressed ALT<span style="color:#7f8c8d;">+Q</span> in any window.
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7a7c7d;">; Retrieve the ID/HWND of the active window</span>
<span style="font-weight:bold;">id</span> := <span style="color:#8e44ad;">WinExist</span>(<span style="color:#f44f4f;">&quot;A&quot;</span>)
<span style="color:#7f8c8d;">MsgBox</span> % <span style="font-weight:bold;">id</span>

<span style="color:#7a7c7d;">; Press Win+↑ to maximize the active window</span>
<span style="color:#7f8c8d;">#Up</span>::<span style="color:#7f8c8d;">WinMaximize</span>, A

<span style="color:#7f8c8d;">#i</span>::
<span style="color:#7f8c8d;">Run</span>, https://www.google.com/
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7f8c8d;">^p</span>::
<span style="color:#7f8c8d;">Run</span>, notepad.exe
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7f8c8d;">~j</span>::
<span style="color:#7f8c8d;">Send</span>, ack
<span style="color:#fdbc4b;font-weight:bold;">return</span>

:*:acheiv::achiev
::achievment::achievement
::acquaintence::acquaintance
:*:adquir::acquir
::aquisition::acquisition
:*:agravat::aggravat
:*:allign::align
::ameria::America
:*:ftw::Free the whales <span style="color:#7a7c7d;">; Hotstring modifiers</span>
this_is_a_label: <span style="color:#7a7c7d;">; label</span>

<span style="color:#27aeae;font-weight:bold;">#IfWinActive</span> Untitled - Notepad
<span style="color:#7f8c8d;">#Space</span>::
<span style="color:#7f8c8d;">MsgBox</span>, You pressed WIN<span style="color:#7f8c8d;">+SPACE</span> in Notepad.
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">Ctrl down</span>}c{<span style="color:#7f8c8d;">Ctrl up</span>}
<span style="color:#7f8c8d;">SendInput</span>, [b]{<span style="color:#7f8c8d;">Ctrl down</span>}v{<span style="color:#7f8c8d;">Ctrl up</span>}[/b]
<span style="color:#fdbc4b;font-weight:bold;">return</span>  <span style="color:#7a7c7d;">; This ends the hotkey. The code below this point will not get triggered.</span>

<span style="color:#7f8c8d;">Send</span>, This text has been typed{!}
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">a</span>}       <span style="color:#7a7c7d;">; WRONG</span>
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">a</span>}{<span style="color:#7f8c8d;">b</span>}{<span style="color:#7f8c8d;">c</span>} <span style="color:#7a7c7d;">; WRONG</span>
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">abc</span>}     <span style="color:#7a7c7d;">; WRONG</span>
<span style="color:#7f8c8d;">Send</span>, abc       <span style="color:#7a7c7d;">; CORRECT</span>
<span style="color:#7f8c8d;">Send</span>, <span style="color:#7f8c8d;">^s</span>                     <span style="color:#7a7c7d;">; Both of these send CTRL+S</span>
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">Ctrl down</span>}s{<span style="color:#7f8c8d;">Ctrl up</span>}  <span style="color:#7a7c7d;">; Both of these send CTRL+S</span>
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">Ctrl down</span>}c{<span style="color:#7f8c8d;">Ctrl up</span>}
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">b down</span>}{<span style="color:#7f8c8d;">b up</span>}
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">Tab down</span>}{<span style="color:#7f8c8d;">Tab up</span>}
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">Up down</span>}  <span style="color:#7a7c7d;">; Press down the up-arrow key.</span>
<span style="color:#fdbc4b;font-weight:bold;">Sleep</span>, <span style="color:#f67400;">1000</span>      <span style="color:#7a7c7d;">; Keep it down for one second.</span>
<span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">Up up</span>}    <span style="color:#7a7c7d;">; Release the up-arrow key.</span>

<span style="color:#7f8c8d;">Send</span>,
(
Line 1
Line 2
Apples are a fruit.
)

<span style="color:#7f8c8d;">Send</span> <span style="color:#27aeae;">%A_Hour%</span>
<span style="color:#8e44ad;">SubStr</span>(<span style="color:#f67400;">37</span> * <span style="color:#f67400;">12</span>, <span style="color:#f67400;">1</span>, <span style="color:#f67400;">2</span>)
<span style="color:#8e44ad;">SubStr</span>(<span style="color:#27aeae;">A_Hour</span> - <span style="color:#f67400;">12</span>, <span style="color:#f67400;">2</span>)
<span style="color:#8e44ad;">SubStr</span>(<span style="color:#27aeae;">A_AhkPath</span>, <span style="color:#8e44ad;">InStr</span>(<span style="color:#27aeae;">A_AhkPath</span>, <span style="color:#f44f4f;">&quot;AutoHotkey&quot;</span>))
<span style="color:#8e44ad;">SubStr</span>(<span style="color:#f44f4f;">&quot;I'm scripting, awesome!&quot;</span>, <span style="color:#f67400;">16</span>)

<span style="color:#7f8c8d;">SetTitleMatchMode</span> RegEx
<span style="color:#7f8c8d;">WinActivate</span> ahk_exe i)<span style="color:#3daee9;">\\</span><span style="color:#da4453;">notepad</span><span style="color:#3daee9;">\.</span><span style="color:#da4453;">exe</span>$  <span style="color:#7a7c7d;">; Match the name part of the full path.</span>
<span style="color:#7f8c8d;">WinActivate</span> ahk_exe im)(*<span style="color:#da4453;">BSR_ANYCRLF</span>)<span style="color:#da4453;">abc</span><span style="color:#3daee9;">\R</span><span style="color:#da4453;">xyz</span>
<span style="color:#7f8c8d;">WinActivate</span> ahk_exe im)(*<span style="color:#da4453;">BSR_ANY</span>[^<span style="color:#da4453;">]</span>]<span style="color:#da4453;">CRLF</span>)<span style="color:#da4453;">abc</span><span style="color:#3daee9;">\R</span><span style="color:#da4453;">xyz</span>

<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">MyVar</span> = <span style="color:#f67400;">5</span>)
{
    <span style="color:#7f8c8d;">MsgBox</span>, MyVar equals <span style="color:#27aeae;">%MyVar%</span><span style="color:#7f8c8d;">!!</span>
    <span style="color:#fdbc4b;font-weight:bold;">ExitApp</span>
}

MyVar = Text
MyVar = <span style="color:#27aeae;">%MyVar2%</span>
MyVar = <span style="color:#27aeae;">%MyVar2%</span> some text <span style="color:#27aeae;">%MyVar3%</span>.
MyVar := <span style="color:#8e44ad;">SubStr</span>(<span style="color:#f44f4f;">&quot;I'm scripting, awesome!&quot;</span>, <span style="color:#f67400;">16</span>)
MyVar := <span style="color:#f44f4f;">&quot;Text&quot;</span>
MyVar := <span style="color:#27aeae;">MyVar2</span>
MyVar := <span style="color:#f67400;">6</span> + <span style="color:#f67400;">8</span> / <span style="color:#f67400;">3</span> * <span style="color:#f67400;">2</span> - <span style="color:#8e44ad;">Sqrt</span>(<span style="color:#f67400;">9</span>)
MyVar := <span style="color:#f44f4f;">&quot;The value of 5 + &quot;</span> <span style="color:#27aeae;">MyVar2</span> <span style="color:#f44f4f;">&quot; is: &quot;</span> <span style="color:#f67400;">5</span> + <span style="color:#27aeae;">MyVar2</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">Var1</span> != <span style="color:#27aeae;">Var2</span>)
    Var1 := <span style="color:#27aeae;">Var2</span> + <span style="color:#f67400;">100</span>

<span style="color:#7a7c7d;">; Some examples showing when to use percents and when not:</span>
Var = Text  <span style="color:#7a7c7d;">; Assign some text to a variable (legacy).</span>
<span style="font-weight:bold;">Number</span> := <span style="color:#f67400;">6</span>  <span style="color:#7a7c7d;">; Assign a number to a variable (expression).</span>
Var2 = <span style="color:#27aeae;">%Var%</span>  <span style="color:#7a7c7d;">; Assign a variable to another (legacy).</span>
Var3 := <span style="color:#27aeae;">Var</span>  <span style="color:#7a7c7d;">; Assign a variable to another (expression).</span>
Var4 .= Var  <span style="color:#7a7c7d;">; Append a variable to the end of another (expression).</span>
Var5 += <span style="color:#27aeae;">Var</span>  <span style="color:#7a7c7d;">; Add the value of a variable to another (expression).</span>
Var5 -= <span style="color:#27aeae;">Var</span>  <span style="color:#7a7c7d;">; Subtract the value of a variable from another (expression).</span>
Var6 := <span style="color:#8e44ad;">SubStr</span>(<span style="color:#27aeae;">Var</span>, <span style="color:#f67400;">2</span>, <span style="color:#f67400;">2</span>)  <span style="color:#7a7c7d;">; Variable inside a function. This is always an expression.</span>
Var7 = <span style="color:#27aeae;">%Var%</span> Text  <span style="color:#7a7c7d;">; Assigns a variable to another with some extra text (legacy).</span>
Var8 := <span style="color:#27aeae;">Var</span> <span style="color:#f44f4f;">&quot; Text&quot;</span>  <span style="color:#7a7c7d;">; Assigns a variable to another with some extra text (expression).</span>
<span style="color:#7f8c8d;">MsgBox</span>, <span style="color:#27aeae;">%Var%</span>  <span style="color:#7a7c7d;">; Variable inside a command.</span>
<span style="color:#7f8c8d;">StringSplit</span>, Var, Var, x  <span style="color:#7a7c7d;">; Variable inside a command that uses InputVar and OutputVar.</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="font-weight:bold;">Number</span> = <span style="color:#f67400;">6</span>)  <span style="color:#7a7c7d;">; Whenever an IF has parentheses, it'll be an expression. So no percent signs.</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">Var</span> != <span style="font-weight:bold;">Number</span>)  <span style="color:#7a7c7d;">; Whenever an IF has parentheses, it'll be an expression. So no percent signs.</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="font-weight:bold;">Number</span> = <span style="color:#f67400;">6</span>  <span style="color:#7a7c7d;">; Without parentheses, the IF is legacy. However, only variables on the 'right side' need percent signs.</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">Var1</span> &lt; <span style="color:#27aeae;">%Var2%</span>  <span style="color:#7a7c7d;">; Without parentheses, the IF is legacy. However, only variables on the 'right side' need percent signs.</span>

MyObject := [<span style="color:#f44f4f;">&quot;one&quot;</span>, <span style="color:#f44f4f;">&quot;two&quot;</span>, <span style="color:#f44f4f;">&quot;three&quot;</span>, <span style="color:#f67400;">17</span>]
Banana := {<span style="color:#f44f4f;">&quot;Color&quot;</span>: <span style="color:#f44f4f;">&quot;Yellow&quot;</span>, <span style="color:#f44f4f;">&quot;Taste&quot;</span>: <span style="color:#f44f4f;">&quot;Delicious&quot;</span>, <span style="color:#f44f4f;">&quot;Price&quot;</span>: <span style="color:#f67400;">3</span>}
MyObject := <span style="color:#8e44ad;">Array</span>(<span style="color:#f44f4f;">&quot;one&quot;</span>, <span style="color:#f44f4f;">&quot;two&quot;</span>, <span style="color:#f44f4f;">&quot;three&quot;</span>, <span style="color:#f67400;">17</span>)
Banana := <span style="color:#8e44ad;">Object</span>(<span style="color:#f44f4f;">&quot;Color&quot;</span>, <span style="color:#f44f4f;">&quot;Yellow&quot;</span>, <span style="color:#f44f4f;">&quot;Taste&quot;</span>, <span style="color:#f44f4f;">&quot;Delicious&quot;</span>, <span style="color:#f44f4f;">&quot;Price&quot;</span>, <span style="color:#f67400;">3</span>)
Banana[<span style="color:#f44f4f;">&quot;Pickled&quot;</span>] := <span style="color:#27aeae;">True</span> <span style="color:#7a7c7d;">; This banana has been pickled. Eww.</span>
Banana.Consistency := <span style="color:#f44f4f;">&quot;Mushy&quot;</span>
Value := <span style="color:#27aeae;">Banana</span>[<span style="color:#f44f4f;">&quot;Color&quot;</span>]
Value := <span style="color:#27aeae;">Banana</span>.<span style="font-weight:bold;">Color</span>
MyObject[<span style="color:#f44f4f;">&quot;NewerKey&quot;</span>] := <span style="color:#f67400;">3.1415</span>
MyObject.NewKey := <span style="color:#f44f4f;">&quot;Shiny&quot;</span>
MyObject.Push(<span style="color:#27aeae;">Value1</span>, <span style="color:#27aeae;">Value2</span>, <span style="color:#27aeae;">Value3</span>...)
Banana.Consistency := <span style="color:#f44f4f;">&quot;&quot;</span>
RemovedValue := <span style="color:#27aeae;">MyObject</span>.<span style="color:#7f8c8d;">Delete</span>(<span style="color:#27aeae;">AnyKey</span>)
NumberOfRemovedKeys := <span style="color:#27aeae;">MyObject</span>.<span style="color:#7f8c8d;">Delete</span>(<span style="color:#27aeae;">FirstKey</span>, <span style="color:#27aeae;">LastKey</span>)
arr := [{}]  <span style="color:#7a7c7d;">; Creates an array containing an object.</span>
arr[<span style="color:#f67400;">1</span>] := {}  <span style="color:#7a7c7d;">; Creates a second object, implicitly freeing the first object.</span>
arr.RemoveAt(<span style="color:#f67400;">1</span>)  <span style="color:#7a7c7d;">; Removes and frees the second object.</span>
x := {}, y := {}             <span style="color:#7a7c7d;">; Create two objects.</span>
x.child := <span style="color:#27aeae;">y</span>, y.parent := <span style="color:#27aeae;">x</span>  <span style="color:#7a7c7d;">; Create a circular reference.</span>
y.parent := <span style="color:#f44f4f;">&quot;&quot;</span>
x := <span style="color:#f44f4f;">&quot;&quot;</span>, y := <span style="color:#f44f4f;">&quot;&quot;</span>
table.base.__Get(<span style="color:#27aeae;">table</span>, <span style="color:#27aeae;">x</span>)[<span style="color:#27aeae;">y</span>] := <span style="color:#27aeae;">content</span>   <span style="color:#7a7c7d;">; A</span>
table.base.__Set(<span style="color:#27aeae;">table</span>, <span style="color:#27aeae;">x</span>, <span style="color:#27aeae;">y</span>, <span style="color:#27aeae;">content</span>)     <span style="color:#7a7c7d;">; B</span>
RemovedValue := <span style="color:#27aeae;">MyObject</span>.<span style="color:#27aeae;">RemoveAt</span>(<span style="color:#27aeae;">Index</span>)
NumberOfRemovedKeys := <span style="color:#27aeae;">MyObject</span>.<span style="color:#27aeae;">RemoveAt</span>(<span style="color:#27aeae;">Index</span>, <span style="color:#27aeae;">Length</span>)
val := <span style="color:#27aeae;">obj</span>.<span style="font-weight:bold;">Property</span> := <span style="color:#f67400;">42</span>
m1 := <span style="font-weight:bold;">new</span> <span style="color:#27aeae;">GMem</span>(<span style="color:#f67400;">0</span>, <span style="color:#f67400;">20</span>)
m2 := {<span style="font-weight:bold;">base</span>: <span style="color:#27aeae;">GMem</span>}.<span style="font-weight:bold;">__New</span>(<span style="color:#f67400;">0</span>, <span style="color:#f67400;">30</span>)
x ? <span style="color:#27aeae;">CallIfTrue</span>() : <span style="color:#27aeae;">CallIfFalse</span>()
ProductIsAvailable := (<span style="font-weight:bold;">Color</span> = <span style="color:#f44f4f;">&quot;Red&quot;</span>)
    ? <span style="color:#27aeae;">false</span>  <span style="color:#7a7c7d;">; We don't have any red products, so don't bother calling the function.</span>
    : <span style="color:#27aeae;">ProductIsAvailableInColor</span>(<span style="color:#27aeae;">Product</span>, <span style="font-weight:bold;">Color</span>)
MyObject.Pop()
<span style="color:#27aeae;">%Var%</span>()

<span style="color:#fdbc4b;font-weight:bold;">Sleep</span> <span style="color:#27aeae;">MillisecondsToWait</span>
<span style="color:#fdbc4b;font-weight:bold;">Sleep</span> <span style="color:#27aeae;">%MillisecondsToWait%</span>
<span style="color:#fdbc4b;font-weight:bold;">Sleep</span> <span style="color:#27aeae;">%</span> <span style="color:#27aeae;">MillisecondsToWait</span>
<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#f67400;">1</span>+<span style="color:#f67400;">1</span>  <span style="color:#7a7c7d;">; Shows &quot;2&quot;</span>
<span style="color:#7f8c8d;">MsgBox</span>   1<span style="color:#7f8c8d;">+</span>1  <span style="color:#7a7c7d;">; Shows &quot;1+1&quot;</span>

<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#f44f4f;">&quot;This is text.&quot;</span>
<span style="color:#7f8c8d;">MsgBox</span>    This is text.
<span style="color:#7f8c8d;">MsgBox</span> %  <span style="color:#27aeae;">A_AhkVersion</span>
<span style="color:#7f8c8d;">MsgBox</span>   <span style="color:#27aeae;">%A_AhkVersion%</span>
<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#27aeae;">%A_AhkVersion%</span>
<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#f44f4f;">&quot;Hello %A_UserName%.&quot;</span>  <span style="color:#7a7c7d;">; Shows &quot;%A_UserName%&quot;</span>
<span style="color:#7f8c8d;">MsgBox</span>    Hello <span style="color:#27aeae;">%A_UserName%</span>.   <span style="color:#7a7c7d;">; Shows your username.</span>
<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#f44f4f;">&quot;Hello &quot;</span> . <span style="color:#27aeae;">A_UserName</span> . <span style="color:#f44f4f;">&quot;.&quot;</span>  <span style="color:#7a7c7d;">; Shows your username.</span>
MyVar := <span style="color:#f44f4f;">&quot;This is text.&quot;</span>
MyVar = This is text.

<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">Var1</span> = <span style="color:#27aeae;">Var2</span>)
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">Var1</span> = <span style="color:#27aeae;">%Var2%</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">Var1</span> &gt;= <span style="font-weight:bold;">Low</span> <span style="font-weight:bold;">and</span> <span style="color:#27aeae;">Var1</span> &lt;= <span style="font-weight:bold;">High</span>)
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">Var1</span> <span style="font-weight:bold;">between</span> <span style="color:#27aeae;">%Low%</span> <span style="font-weight:bold;">and</span> <span style="color:#27aeae;">%High%</span>

<span style="color:#8e44ad;">Format</span>(<span style="color:#f44f4f;">&quot;{:L}{:U}{:T}&quot;</span>, <span style="color:#7f8c8d;">input</span>, <span style="color:#7f8c8d;">input</span>, <span style="color:#7f8c8d;">input</span>)

<span style="color:#7f8c8d;">*#up</span>::<span style="color:#7f8c8d;">MouseMove</span>, 0, -10, 0, R  <span style="color:#7a7c7d;">; Win+UpArrow hotkey =&gt; Move cursor upward</span>
<span style="color:#7f8c8d;">*#Down</span>::<span style="color:#7f8c8d;">MouseMove</span>, 0, 10, 0, R  <span style="color:#7a7c7d;">; Win+DownArrow =&gt; Move cursor downward</span>
<span style="color:#7f8c8d;">*#Left</span>::<span style="color:#7f8c8d;">MouseMove</span>, -10, 0, 0, R  <span style="color:#7a7c7d;">; Win+LeftArrow =&gt; Move cursor to the left</span>
<span style="color:#7f8c8d;">*#Right</span>::<span style="color:#7f8c8d;">MouseMove</span>, 10, 0, 0, R  <span style="color:#7a7c7d;">; Win+RightArrow =&gt; Move cursor to the right</span>

<span style="color:#7f8c8d;">*&lt;#RCtrl</span>::  <span style="color:#7a7c7d;">; LeftWin + RightControl =&gt; Left-click (hold down Control/Shift to Control-Click or Shift-Click).</span>
<span style="color:#7f8c8d;">SendEvent</span> {<span style="color:#7f8c8d;">Blind</span>}{<span style="color:#7f8c8d;">LButton down</span>}
<span style="color:#7f8c8d;">KeyWait</span> RCtrl  <span style="color:#7a7c7d;">; Prevents keyboard auto-repeat from repeating the mouse click.</span>
<span style="color:#7f8c8d;">SendEvent</span> {<span style="color:#7f8c8d;">Blind</span>}{<span style="color:#7f8c8d;">LButton up</span>}
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7f8c8d;">*&lt;#AppsKey</span>::  <span style="color:#7a7c7d;">; LeftWin + AppsKey =&gt; Right-click</span>
<span style="color:#7f8c8d;">SendEvent</span> {<span style="color:#7f8c8d;">Blind</span>}{<span style="color:#7f8c8d;">RButton down</span>}
<span style="color:#7f8c8d;">KeyWait</span> AppsKey  <span style="color:#7a7c7d;">; Prevents keyboard auto-repeat from repeating the mouse click.</span>
<span style="color:#7f8c8d;">SendEvent</span> {<span style="color:#7f8c8d;">Blind</span>}{<span style="color:#7f8c8d;">RButton up</span>}
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#27aeae;font-weight:bold;">#Persistent</span>  <span style="color:#7a7c7d;">; Keep this script running until the user explicitly exits it.</span>
<span style="color:#fdbc4b;font-weight:bold;">SetTimer</span>, <span style="color:#27aeae;">WatchPOV</span>, <span style="color:#f67400;">5</span>
<span style="color:#fdbc4b;font-weight:bold;">return</span>

WatchPOV:
POV := <span style="color:#7f8c8d;">GetKeyState</span>(<span style="color:#f44f4f;">&quot;JoyPOV&quot;</span>)  <span style="color:#7a7c7d;">; Get position of the POV control.</span>
KeyToHoldDownPrev := <span style="color:#27aeae;">KeyToHoldDown</span>  <span style="color:#7a7c7d;">; Prev now holds the key that was down before (if any).</span>

<span style="color:#7a7c7d;">; Some joysticks might have a smooth/continous POV rather than one in fixed increments.</span>
<span style="color:#7a7c7d;">; To support them all, use a range:</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">POV</span> &lt; <span style="color:#f67400;">0</span>)   <span style="color:#7a7c7d;">; No angle to report</span>
    KeyToHoldDown := <span style="color:#f44f4f;">&quot;&quot;</span>
<span style="color:#fdbc4b;font-weight:bold;">else</span> <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">POV</span> &gt; <span style="color:#f67400;">31500</span>)               <span style="color:#7a7c7d;">; 315 to 360 degrees: Forward</span>
    KeyToHoldDown := <span style="color:#f44f4f;">&quot;Up&quot;</span>
<span style="color:#fdbc4b;font-weight:bold;">else</span> <span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">POV</span> <span style="font-weight:bold;">between</span> <span style="color:#f67400;">0</span> <span style="font-weight:bold;">and</span> <span style="color:#f67400;">4500</span>      <span style="color:#7a7c7d;">; 0 to 45 degrees: Forward</span>
    KeyToHoldDown := <span style="color:#f44f4f;">&quot;Up&quot;</span>
<span style="color:#fdbc4b;font-weight:bold;">else</span> <span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">POV</span> <span style="font-weight:bold;">between</span> <span style="color:#f67400;">4501</span> <span style="font-weight:bold;">and</span> <span style="color:#f67400;">13500</span>  <span style="color:#7a7c7d;">; 45 to 135 degrees: Right</span>
    KeyToHoldDown := <span style="color:#f44f4f;">&quot;Right&quot;</span>
<span style="color:#fdbc4b;font-weight:bold;">else</span> <span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">POV</span> <span style="font-weight:bold;">between</span> <span style="color:#f67400;">13501</span> <span style="font-weight:bold;">and</span> <span style="color:#f67400;">22500</span> <span style="color:#7a7c7d;">; 135 to 225 degrees: Down</span>
    KeyToHoldDown := <span style="color:#f44f4f;">&quot;Down&quot;</span>
<span style="color:#fdbc4b;font-weight:bold;">else</span>                                <span style="color:#7a7c7d;">; 225 to 315 degrees: Left</span>
    KeyToHoldDown := <span style="color:#f44f4f;">&quot;Left&quot;</span>

<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">KeyToHoldDown</span> = <span style="color:#27aeae;">KeyToHoldDownPrev</span>)  <span style="color:#7a7c7d;">; The correct key is already down (or no key is needed).</span>
    <span style="color:#fdbc4b;font-weight:bold;">return</span>  <span style="color:#7a7c7d;">; Do nothing.</span>

<span style="color:#7a7c7d;">; Otherwise, release the previous key and press down the new key:</span>
<span style="color:#7f8c8d;">SetKeyDelay</span> -1  <span style="color:#7a7c7d;">; Avoid delays between keystrokes.</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">KeyToHoldDownPrev</span>   <span style="color:#7a7c7d;">; There is a previous key to release.</span>
    <span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">%KeyToHoldDownPrev% up</span>}  <span style="color:#7a7c7d;">; Release it.</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">KeyToHoldDown</span>   <span style="color:#7a7c7d;">; There is a key to press down.</span>
    <span style="color:#7f8c8d;">Send</span>, {<span style="color:#7f8c8d;">%KeyToHoldDown% down</span>}  <span style="color:#7a7c7d;">; Press it down.</span>
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7f8c8d;">&lt;^&gt;!m</span>::<span style="color:#7f8c8d;">MsgBox</span> You pressed AltGr<span style="color:#7f8c8d;">+m</span>.
<span style="color:#7f8c8d;">&lt;^&lt;!m</span>::<span style="color:#7f8c8d;">MsgBox</span> You pressed LeftControl<span style="color:#7f8c8d;">+LeftAlt+m</span>.

<span style="color:#7f8c8d;">AppsKey</span>::<span style="color:#7f8c8d;">ToolTip</span> Press <span style="color:#7f8c8d;">&lt;</span> or <span style="color:#7f8c8d;">&gt;</span> to cycle through windows.
<span style="color:#7f8c8d;">AppsKey Up</span>::<span style="color:#7f8c8d;">ToolTip</span>
<span style="color:#7f8c8d;">~AppsKey &amp; &lt;</span>::<span style="color:#7f8c8d;">Send</span> <span style="color:#7f8c8d;">!+</span>{<span style="color:#7f8c8d;">Esc</span>}
<span style="color:#7f8c8d;">~AppsKey &amp; &gt;</span>::<span style="color:#7f8c8d;">Send</span> <span style="color:#7f8c8d;">!</span>{<span style="color:#7f8c8d;">Esc</span>}

<span style="color:#7a7c7d;">; Press AppsKey and Alt in any order, then slash (/).</span>
<span style="color:#27aeae;font-weight:bold;">#if</span> <span style="color:#7f8c8d;">GetKeyState</span>(<span style="color:#f44f4f;">&quot;AppsKey&quot;</span>, <span style="color:#f44f4f;">&quot;P&quot;</span>)
<span style="color:#7f8c8d;">Alt &amp; /</span>::<span style="color:#7f8c8d;">MsgBox</span> Hotkey activated.

<span style="color:#7a7c7d;">; If the keys are swapped, Alt must be pressed first (use one at a time):</span>
<span style="color:#27aeae;font-weight:bold;">#if</span> <span style="color:#7f8c8d;">GetKeyState</span>(<span style="color:#f44f4f;">&quot;Alt&quot;</span>, <span style="color:#f44f4f;">&quot;P&quot;</span>)
<span style="color:#7f8c8d;">AppsKey &amp; /</span>::<span style="color:#7f8c8d;">MsgBox</span> Hotkey activated.

<span style="color:#7a7c7d;">; [ &amp; ] &amp; \::</span>
<span style="color:#27aeae;font-weight:bold;">#if</span> <span style="color:#7f8c8d;">GetKeyState</span>(<span style="color:#f44f4f;">&quot;[&quot;</span>) &amp;&amp; <span style="color:#7f8c8d;">GetKeyState</span>(<span style="color:#f44f4f;">&quot;]&quot;</span>)
\::<span style="color:#7f8c8d;">MsgBox</span>

<span style="color:#7a7c7d;">; Ctrl+Shift+O to open containing folder in Explorer.</span>
<span style="color:#7a7c7d;">; Ctrl+Shift+E to open folder with current file selected.</span>
<span style="color:#7a7c7d;">; Supports SciTE and Notepad++.</span>
<span style="color:#7f8c8d;">^+o</span>::
<span style="color:#7f8c8d;">^+e</span>::
    editor_open_folder() {
        <span style="color:#7f8c8d;">WinGetTitle</span>, path, A
        <span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#8e44ad;">RegExMatch</span>(<span style="color:#27aeae;">path</span>, <span style="color:#f44f4f;">&quot;\*?\K(.*)\\[^\\]+(?= [-*] )&quot;</span>, <span style="color:#27aeae;">path</span>)
            <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#8e44ad;">FileExist</span>(<span style="color:#27aeae;">path</span>) &amp;&amp; <span style="color:#27aeae;">A_ThisHotkey</span> = <span style="color:#f44f4f;">&quot;^+e&quot;</span>)
                <span style="color:#7f8c8d;">Run</span> explorer.exe /select<span style="color:#3daee9;">`,</span>&quot;<span style="color:#27aeae;">%path%</span>&quot;
            <span style="color:#fdbc4b;font-weight:bold;">else</span>
                <span style="color:#7f8c8d;">Run</span> explorer.exe &quot;<span style="color:#27aeae;">%path1%</span>&quot;
    }

<span style="color:#7f8c8d;">#h</span>::  <span style="color:#7a7c7d;">; Win+H hotkey</span>
<span style="color:#7a7c7d;">; Get the text currently selected. The clipboard is used instead of</span>
<span style="color:#7a7c7d;">; &quot;ControlGet Selected&quot; because it works in a greater variety of editors</span>
<span style="color:#7a7c7d;">; (namely word processors).  Save the current clipboard contents to be</span>
<span style="color:#7a7c7d;">; restored later. Although this handles only plain text, it seems better</span>
<span style="color:#7a7c7d;">; than nothing:</span>
<span style="color:#7f8c8d;">AutoTrim</span> Off  <span style="color:#7a7c7d;">; Retain any leading and trailing whitespace on the clipboard.</span>
ClipboardOld := <span style="color:#27aeae;">ClipboardAll</span>
<span style="color:#27aeae;">Clipboard</span> := <span style="color:#f44f4f;">&quot;&quot;</span>  <span style="color:#7a7c7d;">; Must start off blank for detection to work.</span>
<span style="color:#7f8c8d;">Send</span> <span style="color:#7f8c8d;">^c</span>
<span style="color:#7f8c8d;">ClipWait</span> 1
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">ErrorLevel</span>  <span style="color:#7a7c7d;">; ClipWait timed out.</span>
    <span style="color:#fdbc4b;font-weight:bold;">return</span>
<span style="color:#7a7c7d;">; Replace CRLF and/or LF with `n for use in a &quot;send-raw&quot; hotstring:</span>
<span style="color:#7a7c7d;">; The same is done for any other characters that might otherwise</span>
<span style="color:#7a7c7d;">; be a problem in raw mode:</span>
<span style="color:#7f8c8d;">StringReplace</span>, Hotstring, Clipboard, <span style="color:#3daee9;">``</span>, <span style="color:#3daee9;">````</span>, All  <span style="color:#7a7c7d;">; Do this replacement first to avoid interfering with the others below.</span>
<span style="color:#7f8c8d;">StringReplace</span>, Hotstring, Hotstring, <span style="color:#3daee9;">`r`n</span>, <span style="color:#3daee9;">``</span>r, All  <span style="color:#7a7c7d;">; Using `r works better than `n in MS Word, etc.</span>
<span style="color:#7f8c8d;">StringReplace</span>, Hotstring, Hotstring, <span style="color:#3daee9;">`n</span>, <span style="color:#3daee9;">``</span>r, All
<span style="color:#7f8c8d;">StringReplace</span>, Hotstring, Hotstring, <span style="color:#27aeae;">%A_Tab%</span>, <span style="color:#3daee9;">``</span>t, All
<span style="color:#7f8c8d;">StringReplace</span>, Hotstring, Hotstring, <span style="color:#3daee9;">`;</span>, <span style="color:#3daee9;">```;</span>, All
<span style="color:#27aeae;">Clipboard</span> := <span style="color:#27aeae;">ClipboardOld</span>  <span style="color:#7a7c7d;">; Restore previous contents of clipboard.</span>
<span style="color:#7a7c7d;">; This will move the InputBox's caret to a more friendly position:</span>
<span style="color:#fdbc4b;font-weight:bold;">SetTimer</span>, <span style="color:#27aeae;">MoveCaret</span>, <span style="color:#f67400;">10</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">ErrorLevel</span>  <span style="color:#7a7c7d;">; The user pressed Cancel.</span>
    <span style="color:#fdbc4b;font-weight:bold;">return</span>
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#8e44ad;">InStr</span>(<span style="color:#8e44ad;">Hotstring</span>, <span style="color:#f44f4f;">&quot;:R</span><span style="color:#3daee9;">`::</span><span style="color:#f44f4f;">:&quot;</span>)
{
    <span style="color:#7f8c8d;">MsgBox</span> You didn't provide an abbreviation. The hotstring has not been added.
    <span style="color:#fdbc4b;font-weight:bold;">return</span>
}
<span style="color:#7a7c7d;">; Otherwise, add the hotstring and reload the script:</span>
<span style="color:#7f8c8d;">FileAppend</span>, <span style="color:#3daee9;">`n</span><span style="color:#27aeae;">%Hotstring%</span>, <span style="color:#27aeae;">%A_ScriptFullPath%</span>  <span style="color:#7a7c7d;">; Put a `n at the beginning in case file lacks a blank line at its end.</span>
<span style="color:#7f8c8d;">Reload</span>
<span style="color:#fdbc4b;font-weight:bold;">Sleep</span> <span style="color:#f67400;">200</span>
<span style="color:#7f8c8d;">MsgBox</span>, 4,, The hotstring just added appears to be improperly formatted.
<span style="color:#fdbc4b;font-weight:bold;">IfMsgBox</span>, <span style="font-weight:bold;">Yes</span>, <span style="color:#7f8c8d;">Edit</span>
<span style="color:#fdbc4b;font-weight:bold;">return</span>

MoveCaret:
<span style="color:#fdbc4b;font-weight:bold;">IfWinNotActive</span>, <span style="font-weight:bold;">New</span> <span style="color:#8e44ad;">Hotstring</span>
    <span style="color:#fdbc4b;font-weight:bold;">return</span>
<span style="color:#7a7c7d;">; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.</span>
<span style="color:#7f8c8d;">Send</span> {<span style="color:#7f8c8d;">Home</span>}{<span style="color:#7f8c8d;">Right 3</span>}
<span style="color:#fdbc4b;font-weight:bold;">SetTimer</span>, <span style="color:#27aeae;">MoveCaret</span>, <span style="font-weight:bold;">Off</span>
<span style="color:#fdbc4b;font-weight:bold;">return</span>

<span style="color:#7a7c7d;">; This example also demonstrates one way to implement case conformity in a script.</span>
:C:BTW::  <span style="color:#7a7c7d;">; Typed in all-caps.</span>
:C:Btw::  <span style="color:#7a7c7d;">; Typed with only the first letter upper-case.</span>
: :btw::  <span style="color:#7a7c7d;">; Typed in any other combination.</span>
    case_conform_btw() {
        hs := <span style="color:#27aeae;">A_ThisHotkey</span>  <span style="color:#7a7c7d;">; For convenience and in case we're interrupted.</span>
        <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">hs</span> == <span style="color:#f44f4f;">&quot;:C:BTW&quot;</span>)
            <span style="color:#7f8c8d;">Send</span> BY THE WAY
        <span style="color:#fdbc4b;font-weight:bold;">else</span> <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">hs</span> == <span style="color:#f44f4f;">&quot;:C:Btw&quot;</span>)
            <span style="color:#7f8c8d;">Send</span> By the way
        <span style="color:#fdbc4b;font-weight:bold;">else</span>
            <span style="color:#7f8c8d;">Send</span> by the way
    }

<span style="color:#27aeae;font-weight:bold;">#IfWinActive</span> <span style="font-weight:bold;">ahk_class</span> Notepad
::btw::This replacement text will appear only in Notepad.
<span style="color:#27aeae;font-weight:bold;">#IfWinActive</span>
::btw::This replacement text appears in windows other than Notepad.

<span style="color:#27aeae;font-weight:bold;">#Hotstring</span> EndChars -()[]{}:<span style="color:#7a7c7d;">;'&quot;/\,.?!`n `t</span>

<span style="color:#8e44ad;">Hotstring</span>(<span style="color:#f44f4f;">&quot;EndChars&quot;</span>, <span style="color:#f44f4f;">&quot;-()[]{}:;&quot;</span>)

::btw::
<span style="color:#7f8c8d;">MsgBox</span> You typed &quot;<span style="color:#3daee9;">``</span>btw<span style="color:#3daee9;">``</span>&quot;.
<span style="color:#fdbc4b;font-weight:bold;">return</span>

:*:]d::  <span style="color:#7a7c7d;">; This hotstring replaces &quot;]d&quot; with the current date and time via the commands below.</span>

MyFunction(<span style="color:#27aeae;">FirstParameter</span>, <span style="color:#27aeae;">Second</span>, <span style="color:#fdbc4b;font-weight:bold;">ByRef</span> <span style="color:#27aeae;">Third</span>, <span style="color:#27aeae;">Fourth</span>:=<span style="color:#f44f4f;">&quot;&quot;</span>)
{
    <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="color:#f44f4f;">&quot;a value&quot;</span>
}

<span style="color:#fdbc4b;font-weight:bold;">Loop</span> <span style="color:#f67400;">3</span>
    <span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#27aeae;">MyArray%A_Index%</span>

<span style="color:#7f8c8d;">SysGet</span>, WA, MonitorWorkArea
<span style="color:#7f8c8d;">MsgBox</span>, Left: <span style="color:#27aeae;">%WALeft%</span> -- Top: <span style="color:#27aeae;">%WATop%</span> -- Right: <span style="color:#27aeae;">%WARight%</span> -- Bottom: <span style="color:#27aeae;">%WABottom%</span>.

n := <span style="color:#f67400;">123</span> <span style="color:#f67400;">00123</span> -<span style="color:#f67400;">1.</span>  <span style="color:#f67400;">0x7B</span> <span style="color:#f67400;">0x007B</span> -<span style="color:#f67400;">0x1</span>  <span style="color:#f67400;">3.14159</span>

<span style="color:#7f8c8d;">FileAppend</span>,   <span style="color:#7a7c7d;">; Comment.</span>
<span style="color:#7a7c7d;">; Comment.</span>
( <span style="color:#8e44ad;">LTrim</span> <span style="font-weight:bold;">Join</span>    <span style="color:#7a7c7d;">; Comment.</span>
     <span style="color:#7a7c7d;">; This is not a comment; it is literal. Include the word Comments in the line above to make it a comment.</span>
), C:\File.txt   <span style="color:#7a7c7d;">; Comment.</span>

param := <span style="color:#27aeae;">%A_Index%</span>  <span style="color:#7a7c7d;">; Fetch the contents of the variable whose name is contained in A_Index.</span>

<span style="font-weight:bold;">Add</span>(<span style="color:#27aeae;">X</span>, <span style="color:#27aeae;">Y</span>, <span style="color:#27aeae;">Z</span>:=<span style="color:#f67400;">0</span>) {
    <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="color:#27aeae;">X</span> + <span style="color:#27aeae;">Y</span> + <span style="color:#27aeae;">Z</span>
}

<span style="font-weight:bold;">Join</span>(<span style="color:#27aeae;">sep</span>, <span style="color:#27aeae;">params</span>*) {
    <span style="color:#fdbc4b;font-weight:bold;">for</span> <span style="color:#27aeae;">index</span>,<span style="color:#27aeae;">param</span> <span style="font-weight:bold;">in</span> <span style="color:#27aeae;">params</span>
        str .= param . sep
    <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="color:#8e44ad;">SubStr</span>(<span style="color:#27aeae;">str</span>, <span style="color:#f67400;">1</span>, -<span style="color:#8e44ad;">StrLen</span>(<span style="color:#27aeae;">sep</span>))
}
<span style="color:#7f8c8d;">MsgBox</span> % <span style="font-weight:bold;">Join</span>(<span style="color:#f44f4f;">&quot;</span><span style="color:#3daee9;">`n</span><span style="color:#f44f4f;">&quot;</span>, <span style="color:#f44f4f;">&quot;one&quot;</span>, <span style="color:#f44f4f;">&quot;two&quot;</span>, <span style="color:#f44f4f;">&quot;three&quot;</span>)

LogToFile(<span style="color:#27aeae;">TextToLog</span>)
{
    <span style="color:#fdbc4b;font-weight:bold;">global</span> <span style="color:#27aeae;">LogFileName</span>  <span style="color:#7a7c7d;">; This global variable was previously given a value somewhere outside this function.</span>
    <span style="color:#7f8c8d;">FileAppend</span>, <span style="color:#27aeae;">%TextToLog%</span><span style="color:#3daee9;">`n</span>, <span style="color:#27aeae;">%LogFileName%</span>
}

SetDefaults()
{
    <span style="color:#fdbc4b;font-weight:bold;">global</span>
    MyGlobal := <span style="color:#f67400;">33</span>
    <span style="color:#fdbc4b;font-weight:bold;">local</span> <span style="color:#27aeae;">x</span>, <span style="color:#27aeae;">y</span>:=<span style="color:#f67400;">0</span>, <span style="color:#27aeae;">z</span>
}

LogToFile(<span style="color:#27aeae;">TextToLog</span>)
{
    <span style="color:#fdbc4b;font-weight:bold;">static</span> <span style="color:#27aeae;">LoggedLines</span> := <span style="color:#f67400;">0</span>
    LoggedLines += <span style="color:#f67400;">1</span>
    <span style="color:#fdbc4b;font-weight:bold;">global</span> <span style="color:#27aeae;">LogFileName</span>
    <span style="color:#7f8c8d;">FileAppend</span>, <span style="color:#27aeae;">%LoggedLines%</span>: <span style="color:#27aeae;">%TextToLog%</span><span style="color:#3daee9;">`n</span>, <span style="color:#27aeae;">%LogFileName%</span>
}

GetFromStaticArray(<span style="color:#27aeae;">WhichItemNumber</span>)
{
    <span style="color:#fdbc4b;font-weight:bold;">static</span>
    <span style="color:#fdbc4b;font-weight:bold;">static</span> <span style="color:#27aeae;">FirstCallToUs</span> := <span style="color:#27aeae;">true</span>
    <span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">FirstCallToUs</span>
    {
        FirstCallToUs := <span style="color:#27aeae;">false</span>
        <span style="color:#fdbc4b;font-weight:bold;">Loop</span> <span style="color:#f67400;">10</span>
            StaticArray<span style="color:#27aeae;">%A_Index%</span> := <span style="color:#f44f4f;">&quot;Value #&quot;</span> . <span style="color:#27aeae;">A_Index</span>
    }
    <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="color:#27aeae;">StaticArray%WhichItemNumber%</span>
}

<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">ColorName</span> != <span style="color:#f44f4f;">&quot;&quot;</span> <span style="font-weight:bold;">AND</span> <span style="font-weight:bold;">not</span> <span style="color:#27aeae;">FindColor</span>(<span style="color:#27aeae;">ColorName</span>))
    <span style="color:#7f8c8d;">MsgBox</span> <span style="color:#27aeae;">%ColorName%</span> could not be found.

<span style="font-weight:bold;">class</span> baseObject {
    <span style="color:#fdbc4b;font-weight:bold;">static</span> <span style="color:#27aeae;">foo</span> := <span style="color:#f44f4f;">&quot;bar&quot;</span>
}
baseObject := {<span style="color:#27aeae;">foo</span>: <span style="color:#f44f4f;">&quot;bar&quot;</span>}

thing := {}
thing.foo := <span style="color:#f44f4f;">&quot;bar&quot;</span>
thing.test := <span style="color:#8e44ad;">Func</span>(<span style="color:#f44f4f;">&quot;thing_test&quot;</span>)
thing.test()

thing_test(<span style="font-weight:bold;">this</span>) {
    <span style="color:#7f8c8d;">MsgBox</span> % <span style="font-weight:bold;">this</span>.<span style="color:#27aeae;">foo</span>
}

<span style="font-weight:bold;">class</span> Color
{
    <span style="font-weight:bold;">__New</span>(<span style="color:#27aeae;">aRGB</span>)
    {
        <span style="font-weight:bold;">this</span>.RGB := <span style="color:#27aeae;">aRGB</span>
    }

    <span style="font-weight:bold;">__Delete</span>()
    {
        <span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#f44f4f;">&quot;Delete Color.&quot;</span>
    }

    <span style="color:#fdbc4b;font-weight:bold;">static</span> <span style="color:#7f8c8d;">Shift</span> := {<span style="color:#27aeae;">R</span>:<span style="color:#f67400;">16</span>, <span style="color:#27aeae;">G</span>:<span style="color:#f67400;">8</span>, <span style="color:#27aeae;">B</span>:<span style="color:#f67400;">0</span>}

    <span style="font-weight:bold;">__Get</span>(<span style="color:#27aeae;">aName</span>)
    {
        <span style="color:#7a7c7d;">; </span><span style="color:#81ca2d;background-color:#4d1f24;font-weight:bold;">NOTE</span><span style="color:#7a7c7d;">: Using this.Shift here would cause an infinite loop!</span>
        shift := <span style="font-weight:bold;">Color</span>.<span style="color:#7f8c8d;">Shift</span>[<span style="color:#27aeae;">aName</span>]  <span style="color:#7a7c7d;">; Get the number of bits to shift.</span>
        <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#7f8c8d;">shift</span> != <span style="color:#f44f4f;">&quot;&quot;</span>)  <span style="color:#7a7c7d;">; Is it a known property?</span>
            <span style="color:#fdbc4b;font-weight:bold;">return</span> (<span style="font-weight:bold;">this</span>.<span style="font-weight:bold;">RGB</span> &gt;&gt; <span style="color:#7f8c8d;">shift</span>) &amp; <span style="color:#f67400;">0xff</span>
        <span style="color:#7a7c7d;">; </span><span style="color:#81ca2d;background-color:#4d1f24;font-weight:bold;">NOTE</span><span style="color:#7a7c7d;">: Using 'return' here would break this.RGB.</span>
    }

    <span style="font-weight:bold;">__Set</span>(<span style="color:#27aeae;">aName</span>, <span style="color:#27aeae;">aValue</span>)
    {
        <span style="color:#fdbc4b;font-weight:bold;">if</span> ((<span style="color:#7f8c8d;">shift</span> := <span style="font-weight:bold;">Color</span>.<span style="color:#7f8c8d;">Shift</span>[<span style="color:#27aeae;">aName</span>]) != <span style="color:#f44f4f;">&quot;&quot;</span>)
        {
            aValue &amp;= <span style="color:#f67400;">255</span>  <span style="color:#7a7c7d;">; Truncate it to the proper range.</span>

            <span style="color:#7a7c7d;">; Calculate and store the new RGB value.</span>
            <span style="font-weight:bold;">this</span>.RGB := (<span style="color:#27aeae;">aValue</span> &lt;&lt; <span style="color:#7f8c8d;">shift</span>) | (<span style="font-weight:bold;">this</span>.<span style="font-weight:bold;">RGB</span> &amp; ~(<span style="color:#f67400;">0xff</span> &lt;&lt; <span style="color:#7f8c8d;">shift</span>))

            <span style="color:#7a7c7d;">; 'Return' must be used to indicate a new key-value pair should not be created.</span>
            <span style="color:#7a7c7d;">; This also defines what will be stored in the 'x' in 'x := clr[name] := val':</span>
            <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="color:#27aeae;">aValue</span>
        }
        <span style="color:#7a7c7d;">; </span><span style="color:#81ca2d;background-color:#4d1f24;font-weight:bold;">NOTE</span><span style="color:#7a7c7d;">: Using 'return' here would break this.stored_RGB and this.RGB.</span>
    }

    <span style="color:#7a7c7d;">; Meta-functions can be mixed with properties:</span>
    <span style="font-weight:bold;">RGB</span> {
        <span style="font-weight:bold;">get</span> {
            <span style="color:#7a7c7d;">; Return it in hex format:</span>
            <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="color:#8e44ad;">format</span>(<span style="color:#f44f4f;">&quot;0x{:06x}&quot;</span>, <span style="font-weight:bold;">this</span>.<span style="color:#27aeae;">stored_RGB</span>)
        }
        <span style="font-weight:bold;">set</span> {
            <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="font-weight:bold;">this</span>.<span style="color:#27aeae;">stored_RGB</span> := <span style="color:#27aeae;">value</span>
        }
    }

    <span style="font-weight:bold;">class</span> __Get extends Properties
    {
        R() {
            <span style="color:#fdbc4b;font-weight:bold;">return</span> (<span style="font-weight:bold;">this</span>.<span style="font-weight:bold;">RGB</span> &gt;&gt; <span style="color:#f67400;">16</span>) &amp; <span style="color:#f67400;">255</span>
        }
        G() {
            <span style="color:#fdbc4b;font-weight:bold;">return</span> (<span style="font-weight:bold;">this</span>.<span style="font-weight:bold;">RGB</span> &gt;&gt; <span style="color:#f67400;">8</span>) &amp; <span style="color:#f67400;">255</span>
        }
        B() {
            <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="font-weight:bold;">this</span>.<span style="font-weight:bold;">RGB</span> &amp; <span style="color:#f67400;">255</span>
        }
    }

    <span style="font-weight:bold;">Property</span>[]  <span style="color:#7a7c7d;">; Brackets are optional</span>
    {
        <span style="font-weight:bold;">get</span> {
            <span style="color:#fdbc4b;font-weight:bold;">return</span> ...
        }
        <span style="font-weight:bold;">set</span> {
            <span style="color:#fdbc4b;font-weight:bold;">return</span> ... := <span style="color:#27aeae;">value</span>
        }
    }
}

<span style="font-weight:bold;">class</span> Properties extends FunctionObject
{
    Call(<span style="color:#27aeae;">aTarget</span>, <span style="color:#27aeae;">aName</span>, <span style="color:#27aeae;">aParams</span>*)
    {
        <span style="color:#7a7c7d;">; If this Properties object contains a definition for this half-property, call it.</span>
        <span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#8e44ad;">ObjHasKey</span>(<span style="font-weight:bold;">this</span>, <span style="color:#27aeae;">aName</span>)
            <span style="color:#fdbc4b;font-weight:bold;">return</span> <span style="font-weight:bold;">this</span>[<span style="color:#27aeae;">aName</span>].<span style="color:#27aeae;">Call</span>(<span style="color:#27aeae;">aTarget</span>, <span style="color:#27aeae;">aParams</span>*)
    }
}

MyGet(<span style="font-weight:bold;">this</span>, <span style="color:#27aeae;">Key</span>, <span style="color:#27aeae;">Key2</span>)
MySet(<span style="font-weight:bold;">this</span>, <span style="color:#27aeae;">Key</span>, <span style="color:#27aeae;">Key2</span>, <span style="color:#27aeae;">Value</span>)
MyCall(<span style="font-weight:bold;">this</span>, <span style="color:#27aeae;">Name</span>, <span style="color:#27aeae;">Params</span>)

ClassName := { <span style="font-weight:bold;">__Get</span>: <span style="color:#8e44ad;">Func</span>(<span style="color:#f44f4f;">&quot;MyGet&quot;</span>), <span style="font-weight:bold;">__Set</span>: <span style="color:#8e44ad;">Func</span>(<span style="color:#f44f4f;">&quot;MySet&quot;</span>), <span style="font-weight:bold;">__Call</span>: <span style="color:#8e44ad;">Func</span>(<span style="color:#f44f4f;">&quot;MyCall&quot;</span>) }

red  := <span style="font-weight:bold;">new</span> <span style="font-weight:bold;">Color</span>(<span style="color:#f67400;">0xff0000</span>), red.R -= <span style="color:#f67400;">5</span>
cyan := <span style="font-weight:bold;">new</span> <span style="font-weight:bold;">Color</span>(<span style="color:#f67400;">0</span>), cyan.G := <span style="color:#f67400;">255</span>, cyan.B := <span style="color:#f67400;">255</span>

<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#f44f4f;">&quot;red: &quot;</span> <span style="color:#27aeae;">red</span>.<span style="color:#27aeae;">R</span> <span style="color:#f44f4f;">&quot;,&quot;</span> <span style="color:#27aeae;">red</span>.<span style="color:#27aeae;">G</span> <span style="color:#f44f4f;">&quot;,&quot;</span> <span style="color:#27aeae;">red</span>.<span style="color:#27aeae;">B</span> <span style="color:#f44f4f;">&quot; = &quot;</span> <span style="color:#27aeae;">red</span>.<span style="font-weight:bold;">RGB</span>
<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#f44f4f;">&quot;cyan: &quot;</span> <span style="color:#27aeae;">cyan</span>.<span style="color:#27aeae;">R</span> <span style="color:#f44f4f;">&quot;,&quot;</span> <span style="color:#27aeae;">cyan</span>.<span style="color:#27aeae;">G</span> <span style="color:#f44f4f;">&quot;,&quot;</span> <span style="color:#27aeae;">cyan</span>.<span style="color:#27aeae;">B</span> <span style="color:#f44f4f;">&quot; = &quot;</span> <span style="color:#27aeae;">cyan</span>.<span style="font-weight:bold;">RGB</span>

<span style="color:#7a7c7d;">; This example requires the FunctionObject class in order to work.</span>
blue := <span style="font-weight:bold;">new</span> <span style="font-weight:bold;">Color</span>(<span style="color:#f67400;">0x0000ff</span>)
<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#27aeae;">blue</span>.<span style="color:#27aeae;">R</span> <span style="color:#f44f4f;">&quot;,&quot;</span> <span style="color:#27aeae;">blue</span>.<span style="color:#27aeae;">G</span> <span style="color:#f44f4f;">&quot;,&quot;</span> <span style="color:#27aeae;">blue</span>.<span style="color:#27aeae;">B</span>

x := {<span style="font-weight:bold;">base</span>: {<span style="color:#27aeae;">addr</span>: <span style="color:#8e44ad;">Func</span>(<span style="color:#f44f4f;">&quot;x_Addr&quot;</span>), <span style="font-weight:bold;">__Set</span>: <span style="color:#8e44ad;">Func</span>(<span style="color:#f44f4f;">&quot;x_Setter&quot;</span>)}}

<span style="color:#7a7c7d;">; Assign value, implicitly calling x_Setter to create sub-objects.</span>
x[<span style="color:#f67400;">1</span>,<span style="color:#f67400;">2</span>,<span style="color:#f67400;">3</span>] := <span style="color:#f44f4f;">&quot;...&quot;</span>

<span style="color:#7a7c7d;">; Retrieve value and call example method.</span>
<span style="color:#7f8c8d;">MsgBox</span> % <span style="color:#27aeae;">x</span>[<span style="color:#f67400;">1</span>,<span style="color:#f67400;">2</span>,<span style="color:#f67400;">3</span>] <span style="color:#f44f4f;">&quot;</span><span style="color:#3daee9;">`n</span><span style="color:#f44f4f;">&quot;</span> <span style="color:#27aeae;">x</span>.<span style="color:#27aeae;">addr</span>() <span style="color:#f44f4f;">&quot;</span><span style="color:#3daee9;">`n</span><span style="color:#f44f4f;">&quot;</span> <span style="color:#27aeae;">x</span>[<span style="color:#f67400;">1</span>].<span style="color:#27aeae;">addr</span>() <span style="color:#f44f4f;">&quot;</span><span style="color:#3daee9;">`n</span><span style="color:#f44f4f;">&quot;</span> <span style="color:#27aeae;">x</span>[<span style="color:#f67400;">1</span>,<span style="color:#f67400;">2</span>].<span style="color:#27aeae;">addr</span>()

x_Setter(<span style="color:#27aeae;">x</span>, <span style="color:#27aeae;">p1</span>, <span style="color:#27aeae;">p2</span>, <span style="color:#27aeae;">p3</span>) {
    x[<span style="color:#27aeae;">p1</span>] := <span style="font-weight:bold;">new</span> <span style="color:#27aeae;">x</span>.<span style="font-weight:bold;">base</span>
}

x_Addr(<span style="color:#27aeae;">x</span>) {
    <span style="color:#fdbc4b;font-weight:bold;">return</span> &amp;<span style="color:#27aeae;">x</span>
}

<span style="color:#7f8c8d;">InputBox</span>, OutputVar, Question 1, What is your first name?
<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">OutputVar</span> = <span style="color:#f44f4f;">&quot;Bill&quot;</span>)
    <span style="color:#7f8c8d;">MsgBox</span>, That's an awesome name<span style="color:#3daee9;">`,</span> <span style="color:#27aeae;">%OutputVar%</span>.

<span style="color:#7f8c8d;">InputBox</span>, OutputVar2, Question 2, Do you like AutoHotkey?
<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">OutputVar2</span> = <span style="color:#f44f4f;">&quot;yes&quot;</span>)
    <span style="color:#7f8c8d;">MsgBox</span>, Thank you for answering <span style="color:#27aeae;">%OutputVar2%</span><span style="color:#3daee9;">`,</span> <span style="color:#27aeae;">%OutputVar%</span><span style="color:#7f8c8d;">!</span> We will become great friends.
<span style="color:#fdbc4b;font-weight:bold;">else</span>
    <span style="color:#7f8c8d;">MsgBox</span>, <span style="color:#27aeae;">%OutputVar%</span><span style="color:#3daee9;">`,</span> That makes me sad.

<span style="color:#7f8c8d;">MsgBox</span>, 4,, Would you like to continue?
<span style="color:#fdbc4b;font-weight:bold;">IfMsgBox</span>, <span style="font-weight:bold;">No</span>
    <span style="color:#fdbc4b;font-weight:bold;">return</span>  <span style="color:#7a7c7d;">; If No, stop the code from going further.</span>
<span style="color:#7f8c8d;">MsgBox</span>, You pressed YES.  <span style="color:#7a7c7d;">; Otherwise, the user picked yes.</span>

<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">car</span> = <span style="color:#f44f4f;">&quot;old&quot;</span>)
{
    <span style="color:#7f8c8d;">MsgBox</span>, The car is really old.
    <span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">wheels</span> = <span style="color:#f44f4f;">&quot;flat&quot;</span>)
    {
        <span style="color:#7f8c8d;">MsgBox</span>, This car is not safe to drive.
        <span style="color:#fdbc4b;font-weight:bold;">return</span>
    }
    <span style="color:#fdbc4b;font-weight:bold;">else</span>
    {
        <span style="color:#7f8c8d;">MsgBox</span>, Be careful<span style="color:#7f8c8d;">!</span> This old car will be dangerous to drive.
    }
}
<span style="color:#fdbc4b;font-weight:bold;">else</span>
{
    <span style="color:#7f8c8d;">MsgBox</span>, My<span style="color:#3daee9;">`,</span> what a shiny new vehicle you have there.
}

<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="font-weight:bold;">Color</span> = <span style="color:#f44f4f;">&quot;Red&quot;</span> <span style="font-weight:bold;">or</span> <span style="font-weight:bold;">Color</span> = <span style="color:#f44f4f;">&quot;Green&quot;</span>  <span style="font-weight:bold;">or</span> <span style="font-weight:bold;">Color</span> = <span style="color:#f44f4f;">&quot;Blue&quot;</span>   <span style="color:#7a7c7d;">; Comment.</span>
    <span style="font-weight:bold;">or</span> <span style="font-weight:bold;">Color</span> = <span style="color:#f44f4f;">&quot;Black&quot;</span> <span style="font-weight:bold;">or</span> <span style="font-weight:bold;">Color</span> = <span style="color:#f44f4f;">&quot;Gray&quot;</span> <span style="font-weight:bold;">or</span> <span style="font-weight:bold;">Color</span> = <span style="color:#f44f4f;">&quot;White&quot;</span>)   <span style="color:#7a7c7d;">; Comment.</span>
    <span style="font-weight:bold;">and</span> ProductIsAvailableInColor(Product, Color)   <span style="color:#7a7c7d;">; Comment.</span>

<span style="color:#fdbc4b;font-weight:bold;">if</span> (<span style="color:#27aeae;">codepage</span> != <span style="color:#f44f4f;">&quot;&quot;</span>)
    codepage := <span style="color:#f44f4f;">&quot; /CP&quot;</span> . <span style="color:#27aeae;">codepage</span>
cmd=&quot;<span style="color:#27aeae;">%A_AhkPath%</span>&quot;<span style="color:#27aeae;">%codepage%</span> &quot;<span style="color:#3daee9;">`%</span>1&quot; <span style="color:#3daee9;">`%</span><span style="color:#7f8c8d;">*</span>
key=AutoHotkeyScript\Shell\Open\Command
<span style="color:#fdbc4b;font-weight:bold;">if</span> <span style="color:#27aeae;">A_IsAdmin</span>    <span style="color:#7a7c7d;">; Set for all users.</span>
    <span style="color:#7f8c8d;">RegWrite</span>, REG_SZ, HKCR, <span style="color:#27aeae;">%key%</span>,, <span style="color:#27aeae;">%cmd%</span>
<span style="color:#fdbc4b;font-weight:bold;">else</span>            <span style="color:#7a7c7d;">; Set for current user only.</span>
    <span style="color:#7f8c8d;">RegWrite</span>, REG_SZ, HKCU, Software\Classes\<span style="color:#27aeae;">%key%</span>,, <span style="color:#27aeae;">%cmd%</span>

<span style="color:#7f8c8d;">^j</span>:: <span style="color:#7a7c7d;">; hotkey label</span>
<span style="color:#7f8c8d;">MsgBox</span>, You typed btw.
</pre></body></html>
